﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="FinanceAdviser.GroupDetailPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:FinanceAdviser"
    xmlns:data="using:FinanceAdviser.Data"
    xmlns:common="using:FinanceAdviser.Common"
    xmlns:tiles="using:FinanceAdviser.VariableTemplate"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">


	 <Page.TopAppBar>
        <AppBar x:Name="TopApp" Padding="10,0,10,0" MinHeight="110" Background="#F9161616" BorderBrush="#F9161616">
            <Grid Height="100" Margin="10,0,0,0">
                <StackPanel Margin="0" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left">
                    <Button x:Name="btnHome" Tag="Home" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal" VerticalAlignment="Center" Padding="0" Style="{StaticResource TopAppbarBtnStyle}" Click="btnHome_Click"  >
                        <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="93" Margin="0" Width="93" Background="#19259511">
                            <Image Source="Assets/AppBar/TopAppBar1.png" Margin="0"/>
                        </Grid>
                    </Button>
                    <Button x:Name="btnPortfolio" Tag="Portfolio" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal" VerticalAlignment="Center" Padding="0" Style="{StaticResource TopAppbarBtnStyle}" Margin="10,0,0,0"  >
                    	<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="93" Margin="0" Width="93" Background="#19259511">
                    		<Image Source="Assets/AppBar/TopAppBar2.png" Margin="0"/>
                    	</Grid>
                    </Button>
                    <Button x:Name="btnMyGoals" Tag="My Goals" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal" VerticalAlignment="Center" Padding="0" Style="{StaticResource TopAppbarBtnStyle}" Margin="10,0,0,0"  >
                    	<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="93" Margin="0" Width="93" Background="#19259511">
                    		<Image Source="Assets/AppBar/TopAppBar3.png" Margin="0"/>
                    	</Grid>
                    </Button>
                    <Button x:Name="btnEquityTracker" Tag="Equity tracker" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal" VerticalAlignment="Center" Padding="0" Style="{StaticResource TopAppbarBtnStyle}" Margin="10,0,0,0"  >
                    	<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="93" Margin="0" Width="93" Background="#19259511">
                    		<Image Source="Assets/AppBar/TopAppBar4.png" Margin="0"/>
                    	</Grid>
                    </Button>
                    <Button x:Name="btnLoanCalculator" Tag="Loan Calculator" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal" VerticalAlignment="Center" Padding="0" Style="{StaticResource TopAppbarBtnStyle}" Margin="10,0,0,0"  >
                    	<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="93" Margin="0" Width="93" Background="#19259511">
                    		<Image Source="Assets/AppBar/TopAppBar5.png" Margin="0"/>
                    	</Grid>
                    </Button>
                    <Button x:Name="btnMyAccounts" Tag="MyAccounts" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal" VerticalAlignment="Center" Padding="0" Style="{StaticResource TopAppbarBtnStyle}" Margin="10,0,0,0"  >
                    	<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="93" Margin="0" Width="93" Background="#19259511">
                    		<Image Source="Assets/AppBar/TopAppBar6.png" Margin="0"/>
                    	</Grid>
                    </Button>
                    <Button x:Name="btnFixedDeposits" Tag="Fixed Deposits" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal" VerticalAlignment="Center" Padding="0" Style="{StaticResource TopAppbarBtnStyle}" Margin="10,0,0,0"  >
                    	<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="93" Margin="0" Width="93" Background="#19259511">
                    		<Image Source="Assets/AppBar/TopAppBar7.png" Margin="0"/>
                    	</Grid>
                    </Button>
                </StackPanel>
            </Grid>
        </AppBar>
    </Page.TopAppBar>
    
    
 <Page.Resources>



        <!--
            Collection of grouped items displayed by this page, bound to a subset
            of the complete item list because items in groups cannot be virtualized
        -->
        <CollectionViewSource
            x:Name="groupedItemsViewSource"
            Source="{Binding Groups}"
            IsSourceGrouped="true"
            ItemsPath="Items"
            d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:GroupDataSource, IsDesignTimeCreatable=True}}"/>

        <tiles:VariableTiles x:Key="MyTemplateSelectorObj" 
                             
                             RedTemplate="{StaticResource RedItemTemplate}"
                             GreenTemplate="{StaticResource GreenItemTemplate}"
                             WhiteTemplate="{StaticResource WhiteItemTemplate}"
                             NormalTemplate="{StaticResource NormalItemTemplate}"
                             FixedDepositTemplate="{StaticResource FixedDepositItemTemplate}">


        </tiles:VariableTiles>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">

	<Grid.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#FF0A2C4E"/>
                <GradientStop Color="#FF191919" Offset="1"/>
            </LinearGradientBrush>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Horizontal scrolling grid used in most view states -->
        <tiles:VariableTileControl
        			x:Name="itemGridView"
        			AutomationProperties.AutomationId="ItemGridView"
        			AutomationProperties.Name="Grouped Items"
        			Margin="0,8,0,0"
        			Padding="101,0,40,20"
        			ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
        			ItemTemplateSelector="{StaticResource MyTemplateSelectorObj}"
        			SelectionMode="None"
        			IsItemClickEnabled="True"
        			ItemClick="ItemView_ItemClick" HorizontalContentAlignment="Left" ScrollViewer.HorizontalScrollBarVisibility="Auto" Grid.Row="1">

            <tiles:VariableTileControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Orientation="Horizontal" Margin="1,0,60,0"/>
                </ItemsPanelTemplate>
            </tiles:VariableTileControl.ItemsPanel>
            <tiles:VariableTileControl.GroupStyle>
                <GroupStyle >
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                           <!-- <StackPanel Margin="1,0,0,6" Orientation="Horizontal">
                                <Button
        									AutomationProperties.Name="Group Title"
        									Content="{Binding Title}"
        									Click="Header_Click"
        									Style="{StaticResource TextButtonStyle}"  Foreground="#FFFFFFFF" FontFamily="Segoe UI" FontSize="32" FontWeight="Light" Background="#FFD71921"/>
                                <TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="10,0,0,10" Style="{StaticResource GroupHeaderTextStyle}" Foreground="#FFFFFFFF" FontSize="32"/>
                                        <TextBlock x:Name="txtVideo" HorizontalAlignment="Right" TextWrapping="Wrap" Text="{Binding Sub}" VerticalAlignment="Bottom" Foreground="#FFC4261D" Margin="140,21,0,0" FontFamily="Segoe UI" FontSize="16" Visibility="{Binding SubTl}"/>
                                        <TextBlock x:Name="txtPicture" HorizontalAlignment="Right" TextWrapping="Wrap" Text="{Binding Sub2}" VerticalAlignment="Bottom" Foreground="#FFC4261D" Margin="275,21,0,0" FontFamily="Segoe UI" FontSize="16" Visibility="{Binding SubT2}"/>
                            </StackPanel>-->
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                    <GroupStyle.Panel>
                        <ItemsPanelTemplate>
                            <VariableSizedWrapGrid ItemHeight="5" ItemWidth="5" MaximumRowsOrColumns="110" Orientation="Vertical" Margin="0,0,80,0"/>
                        </ItemsPanelTemplate>
                    </GroupStyle.Panel>
                </GroupStyle>
            </tiles:VariableTileControl.GroupStyle>
        </tiles:VariableTileControl>

        <!-- Vertical scrolling list only used when snapped -->
        <ListView
            x:Name="itemListView"
            AutomationProperties.AutomationId="ItemListView"
            AutomationProperties.Name="Grouped Items"
            Grid.Row="1"
            Visibility="Collapsed"
            Margin="0,-10,0,0"
            Padding="10,0,0,60"
            ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
            ItemTemplate="{StaticResource Standard80ItemTemplate}"
            SelectionMode="None"
            IsSwipeEnabled="false"
            IsItemClickEnabled="True"
            ItemClick="ItemView_ItemClick">

            <ListView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <Grid Margin="7,7,0,0">
                                <Button
                                    AutomationProperties.Name="Group Title"
                                    Click="Header_Click"
                                    Style="{StaticResource TextPrimaryButtonStyle}">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
                                        <TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>
                                    </StackPanel>
                                </Button>
                            </Grid>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </ListView.GroupStyle>
        </ListView>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}" Margin="20,0,36,46"/>
            <TextBlock x:Name="pageTitle" Grid.Column="1" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}" Text="Scrips" Margin="0,0,30,50"/>
            <Image x:Name="image" HorizontalAlignment="Right" Width="212" Source="Assets/Logo.png" Margin="0,0,40,0" Grid.Column="1" VerticalAlignment="Center"/>
            <ComboBox x:Name="comboBox" HorizontalAlignment="Left" VerticalAlignment="Bottom" Grid.Column="1" FontSize="26.667" Foreground="White" Background="{x:Null}" BorderBrush="{x:Null}" SelectedIndex="0" Style="{StaticResource SortComboBoxStyle}" MinWidth="100" Margin="0">
            	<ComboBoxItem Content="Sort by" Foreground="White" Style="{StaticResource SortComboBoxItemStyle}" FontSize="16" MinWidth="100"/>
            	<ComboBoxItem Content="Sort by" Foreground="White" Style="{StaticResource SortComboBoxItemStyle}" FontSize="16" MinWidth="100"/>
            	<ComboBoxItem Content="Sort by" Foreground="White" Style="{StaticResource SortComboBoxItemStyle}" FontSize="16" MinWidth="100"/>
            	<ComboBoxItem Content="Sort by" Foreground="White" Style="{StaticResource SortComboBoxItemStyle}" FontSize="16" MinWidth="100"/>
            	<ComboBoxItem Content="Sort by" Foreground="White" Style="{StaticResource SortComboBoxItemStyle}" FontSize="16" MinWidth="100"/>
            	<ComboBoxItem Content="Sort by" Foreground="White" Style="{StaticResource SortComboBoxItemStyle}" FontSize="16" MinWidth="100"/>
            	<ComboBoxItem Content="Sort by" Foreground="White" Style="{StaticResource SortComboBoxItemStyle}" FontSize="16" MinWidth="100"/>
            </ComboBox>
        </Grid>
        <ScrollViewer x:Name="scvSnaped" Grid.Row="1" Style="{StaticResource VerticalScrollViewerStyle}" Visibility="Collapsed">
        	<Grid Margin="1,0,0,0">
        		<tiles:VariableTileControl
        			x:Name="itemGridView2"
        			AutomationProperties.AutomationId="ItemGridView"
        			AutomationProperties.Name="Grouped Items"
        			Margin="0"
        			Padding="0"
        			ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
        			ItemTemplateSelector="{StaticResource MyTemplateSelectorObj}"
        			SelectionMode="None"
        			IsItemClickEnabled="True"
        			ItemClick="ItemView_ItemClick" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalAlignment="Center" Background="#00000000">

        			<tiles:VariableTileControl.ItemsPanel>
        				<ItemsPanelTemplate>
        					<VirtualizingStackPanel Orientation="Vertical" Margin="10,0,0,0"/>
        				</ItemsPanelTemplate>
        			</tiles:VariableTileControl.ItemsPanel>
        			<tiles:VariableTileControl.GroupStyle>
        				<GroupStyle >
        					<GroupStyle.HeaderTemplate>
        						<DataTemplate>
        							<StackPanel Margin="1,0,0,6" Orientation="Vertical">
                    					<!--<TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="10,0,0,10" Style="{StaticResource GroupHeaderTextStyle}" Foreground="#FFFFFFFF" FontSize="32"/>
                                        <TextBlock x:Name="txtVideo" HorizontalAlignment="Right" TextWrapping="Wrap" Text="{Binding Sub}" VerticalAlignment="Bottom" Foreground="#FFC4261D" Margin="140,21,0,0" FontFamily="Segoe UI" FontSize="16" Visibility="{Binding SubTl}"/>
                                        <TextBlock x:Name="txtPicture" HorizontalAlignment="Right" TextWrapping="Wrap" Text="{Binding Sub2}" VerticalAlignment="Bottom" Foreground="#FFC4261D" Margin="275,21,0,0" FontFamily="Segoe UI" FontSize="16" Visibility="{Binding SubT2}"/>

        								<Button
        									AutomationProperties.Name="Group Title"
        									Content="{Binding Title}"
		 									
        									Style="{StaticResource TextButtonStyle}"  Foreground="#FFFFFFFF" FontFamily="Segoe UI" FontSize="32" FontWeight="Light" Background="#FFD71921"/>-->
        							</StackPanel>
        						</DataTemplate>
        					</GroupStyle.HeaderTemplate>
        					<GroupStyle.Panel>
        						<ItemsPanelTemplate>
        							<VariableSizedWrapGrid ItemHeight="5" ItemWidth="5" MaximumRowsOrColumns="110" Orientation="Horizontal" Margin="0,0,0,0"/>
        						</ItemsPanelTemplate>
        					</GroupStyle.Panel>
        				</GroupStyle>
        			</tiles:VariableTileControl.GroupStyle>
        		</tiles:VariableTileControl>
        	</Grid>
        </ScrollViewer>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Padding">
                            <DiscreteObjectKeyFrame KeyTime="0">
                            	<DiscreteObjectKeyFrame.Value>
                            		<Thickness>100,0,10,56</Thickness>
                            	</DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!--
                    The back button and title have different styles when snapped, and the list representation is substituted
                    for the grid displayed in all other view states
                -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0">
                            	<DiscreteObjectKeyFrame.Value>
                            		<Visibility>Collapsed</Visibility>
                            	</DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="scvSnaped">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Visibility>Visible</Visibility>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="image">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Visibility>Collapsed</Visibility>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="pageTitle">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Thickness>-31,0,30,71</Thickness>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="comboBox">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Thickness>-35,0,0,12</Thickness>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="backButton">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Thickness>20,0,36,35</Thickness>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0" Storyboard.TargetProperty="(TextBlock.FontSize)" Storyboard.TargetName="pageTitle" d:IsOptimized="True" To="40"/>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="TopApp">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Visibility>Collapsed</Visibility>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.Padding)" Storyboard.TargetName="itemGridView">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Thickness>101,0,40,20</Thickness>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
